<?php

namespace App\Http\Controllers;

use App\Http\Response;
use Laravel\Lumen\Routing\Controller as BaseController;

class Controller extends BaseController
{
    //成功
    protected  function success($data = []){
        return Response::success($data);
    }

    //error
    protected function  error($msg = '',$code = 400,$data = []){
        return Response::errors(['code'=>$code,'message'=>$msg]);
    }

    public function getImgUrl($value)
    {
        $preg = "/^http(s)?:\\/\\/.+/";
        if(preg_match($preg,$value)){
            return $value;
        }else{
            return env('FILE_URL').'/uploads/'.$value;
        }

    }
}
